<?php
/**
 * Created by PhpStorm.
 * User: 65736
 * Date: 2019/4/8 0008
 * Time: 20:33
 */

namespace app\crontab\controller;


use think\Config;
use think\Controller;

class CrontabCommon extends Controller
{
    /**
     * 模块名称
     * @var string
     */
    protected $module_name;

    /**
     * 控制器名称
     * @var string
     */
    protected $controller_name;

    /**
     * 方法名称
     * @var string
     */
    protected $action_name;

    /**
     * 请求参数集合
     * @var array
     */
    protected $param = [];

    /**
     * 初始化方法
     */
    protected function _initialize() {
        parent::_initialize();
        // 强制CLI
        if ( !IS_CLI ) die("Crontab Must Run in Cli Mode");
        // 初始化属性
        $this->module_name = $this->request->module();
        $this->controller_name = $this->request->controller();
        $this->action_name = $this->request->action();
        // 加载项目配置
        Config::load(APP_PATH . $this->module_name . DS ."config" . CONF_EXT);
        // 初始化请求参数
        $this->init_param();
    }

    /**
     * 初始化请求参数
     */
    private function init_param() {
        $param = $this->request->param();
        $this->param = $param?:[];
    }



}